<?php

namespace app\api\controller\v1;

use app\Request;
use app\services\Index\IndexService;
use app\services\statistics\StaticStoreProductServices;

class IndexController
{
    public function home(Request $request)
    {
        $indexService = app()->make(IndexService::class);
        $list = $indexService->indexList($request->user());
        return app('json')->success($list);
    }

    public function homeProducts(Request $request)
    {
        $label_id = $request->param('label_id', 0);
        $indexService = app()->make(IndexService::class);

        $list = $indexService->getHomeProductList($label_id);
        $param = ['uid'=>$request->uid(), 'list'=>$list['list'], 'type'=>1];
        $staticService = app()->make(StaticStoreProductServices::class);
        $staticService->adds_static($param);

        return app('json')->success($list);
    }

}